package example.controller;


import java.util.List;
import example.common.page.TableDataInfo;
import example.dto.ExportExcelDTO;
import example.entity.TaskList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import example.service.ITaskListService;
import  example.common.AjaxResult;

import javax.servlet.http.HttpServletResponse;


/**
 * 借调历史Controller
 *
 * @author ruoyi
 * @date 2024-07-22
 */
@RestController
@RequestMapping("/api/task")
public class TaskListController extends BaseController
{
    @Autowired
    private ITaskListService taskListService;

    /**
     * 查询借调历史列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TaskList taskList)
    {
        startPage();
        List<TaskList> list = taskListService.selectTaskListList(taskList);
        return getDataTable(list);
    }

    /**
     * 获取借调历史详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(taskListService.selectTaskListById(id));
    }

    /**
     * 新增借调历史
     */
    @PostMapping
    public AjaxResult add(@RequestBody TaskList taskList)
    {
        return toAjax(taskListService.insertTaskList(taskList));
    }

    /**
     * 修改借调历史
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody TaskList taskList)
    {
        return toAjax(taskListService.updateTaskList(taskList));
    }

    /**
     * 删除借调历史
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(taskListService.deleteTaskListByIds(ids));
    }


    /**
     * 导出productionManagement列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestBody TaskList taskList)
    {
        taskListService.export(response,taskList);
    }
}
